package com.gec.system.front.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gec.system.front.FrontUser;
import com.gec.system.front.service.FrontUserService;
import com.gec.system.front.mapper.FrontUserMapper;
import com.gec.system.system.SysUser;
import com.gec.system.vo.RouterVo;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 18236
 * @description 针对表【front_user(用户表)】的数据库操作Service实现
 * @createDate 2024-09-27 13:28:05
 */
@Service
public class FrontUserServiceImpl extends ServiceImpl<FrontUserMapper, FrontUser>
        implements FrontUserService{



    @Override
    public FrontUser getFrontUserName(String username) {
        QueryWrapper<FrontUser> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public Map<String, Object> getUserInfo(String username) {
        HashMap<String, Object> map = new HashMap<>();
        FrontUser frontUser = this.getFrontUserName(username);
        if (frontUser == null) {
            map.put("name", null);
            map.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
            map.put("roles",  "[admin]");
            map.put("username",null);
        }
        log.warn(String.valueOf(frontUser.getId()));
        map.put("name", frontUser.getUsername());
        map.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("roles",  "[admin]");
        map.put("username",baseMapper.selectById(frontUser.getId()));
        return map;

    }
}




